/*
 * Timer.h
 *
 *  Created on: Feb 14, 2012
 *      Author: Michael Anderson
 *      Part of Team 955 Battery Cart project
 *      compiled on Eclipse with Arduino libraries and avr-gcc
 */

#ifndef TIMER_H_
#define TIMER_H_

inline uint32_t getMillisSince(uint32_t oldMillis, uint32_t newMillis) {
    return abs(newMillis - oldMillis);
}

inline double getSecondsSince(uint32_t oldMillis, uint32_t newMillis) {
    return (double)getMillisSince(oldMillis, newMillis) / 1000;
}

inline double getMinutesSince(uint32_t oldMillis, uint32_t newMillis) {
    return (double)(getMillisSince(oldMillis, newMillis) / 1000) / 60;
}

inline double getHoursSince(uint32_t oldMillis, uint32_t newMillis) {
    return (double)(getMillisSince(oldMillis, newMillis) / 1000 / 60) / 60;
}

#endif /* TIMER_H_ */
